현재 위치: > 함수 카테고리 모음> property_exists

property_exists

객체 나 클래스 에이 속성이 있는지 확인하십시오
이름:property_exists
분류:수업과 대상
사용 언어:php
한 줄 설명:객체 또는 클래스에 지정된 속성이 있는지 확인합니다.

함수 이름 : property_exists ()

함수 설명 : property_exists () 함수 객체 또는 클래스에 지정된 속성이 있는지 확인합니다.

매개 변수 :

  • $ 클래스 : 필수. 확인할 클래스 이름 또는 개체.
  • $ 속성 : 필수. 확인할 속성 이름.

반품 값 :

  • 부동산이 존재하고 접근 할 수있는 경우 True를 반환합니다.
  • 속성이 존재하지 않거나 액세스 할 수없는 경우 False가 반환됩니다.

해당 버전 : PHP 4, PHP 5, PHP 7

사용 예 :

  1. 클래스에 지정된 속성이 있는지 확인하십시오.
 class MyClass { public $name = "John"; private $age = 25; } $object = new MyClass(); if (property_exists($object, 'name')) { echo "The 'name' property exists."; } else { echo "The 'name' property does not exist."; } // 输出:The 'name' property exists.
  1. 객체에 지정된 속성이 있는지 확인하십시오.
 class MyClass { public $name = "John"; private $age = 25; } $object = new MyClass(); if (property_exists($object, 'age')) { echo "The 'age' property exists."; } else { echo "The 'age' property does not exist."; } // 输出:The 'age' property does not exist.
  1. 클래스 이름에 지정된 정적 속성이 있는지 확인하십시오.
 class MyClass { public static $name = "John"; private static $age = 25; } if (property_exists('MyClass', 'name')) { echo "The 'name' static property exists."; } else { echo "The 'name' static property does not exist."; } // 输出:The 'name' static property exists.
  1. 클래스 이름에 지정된 정적 개인 속성이 있는지 확인하십시오.
 class MyClass { public static $name = "John"; private static $age = 25; } if (property_exists('MyClass', 'age')) { echo "The 'age' static property exists."; } else { echo "The 'age' static property does not exist."; } // 输出:The 'age' static property does not exist.
유사한 함수
  • 객체 속성으로 구성된 연관 배열을 당신에게 편지로 돌아갑니다. get_object_vars

    get_object_vars

    객체속성으로구성된연관배열을당신에게편지
  • 지정된 특성이 존재하는지 확인하십시오 trait_exists

    trait_exists

    지정된특성이존재하는지확인하십시오
  • 객체 가이 클래스에 속하는지 확인 하거나이 클래스를 부모 클래스 중 하나로 사용하는지 확인하십시오. 객체가 해당 클래스에 속 하거나이 개체의 부모 클래스 인 경우 true를 반환하십시오. is_a

    is_a

    객체가이클래스에속하는지확인하거나이클래
  • 객체의 클래스 이름을 반환하십시오 get_class

    get_class

    객체의클래스이름을반환하십시오
  • 클래스 방법이 존재하는지 확인하십시오 method_exists

    method_exists

    클래스방법이존재하는지확인하십시오
  • 클래스가 정의되어 있는지 확인하십시오 class_exists

    class_exists

    클래스가정의되어있는지확인하십시오
  • 객체 나 클래스 에이 속성이 있는지 확인하십시오 property_exists

    property_exists

    객체나클래스에이속성이있는지확인하십시오
  • 정의 된 모든 특성의 배열을 반환합니다 get_declared_traits

    get_declared_traits

    정의된모든특성의배열을반환합니다